import { createApp } from 'vue'
import App from './App.vue'

console.log('项目启动的主文件 - 主入口文件 ')
const app = createApp(App)

import './styles/index.scss'

import router from './router';
app.use(router)

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
app.use(ElementPlus)

import CaptchaBtn from './components/CaptchaBtn.vue'
import MyTitle from './components/MyTitle.vue'
import DiaLogForm from './components/DiaLogForm.vue'
import SearchTable from './components/SearchTable.vue'
import UploadFile from './components/UploadFile.vue'
import FormAdd from './components/FormAdd.vue'
import Tinymce from './components/Tinymce/Tinymce.vue'
app.component("CaptchaBtn", CaptchaBtn)
app.component("MyTitle", MyTitle)
app.component("DiaLogForm", DiaLogForm)
app.component("SearchTable", SearchTable)
app.component("UploadFile", UploadFile)
app.component("FormAdd", FormAdd)
app.component("Tinymce", Tinymce)

import { createPinia } from 'pinia'
app.use(createPinia())

app.directive('focus', {
    created(el, binding, vnode, prevVnode) {
    },
    beforeMount(el, binding, vnode, prevVnode) { },
    mounted(el, binding, vnode, prevVnode) {
        el.focus()
    },
    beforeUpdate(el, binding, vnode, prevVnode) { },
    updated(el, binding, vnode, prevVnode) { },
    beforeUnmount(el, binding, vnode, prevVnode) { },
    unmounted(el, binding, vnode, prevVnode) { }
})

import moment from 'moment'
app.config.globalProperties.$filters = {
    timeFormat(value?: any, str?: any) {
        if (!value) return '';
        str = str || 'YYYY-MM-DD HH:mm:ss'
        return moment(value).format(str)
    },
    telformat(value?: any, str?: any) {
        if (!value) return '';
        str = str || '-';
        value = value.toString().split("");
        value.splice(3, 0, str);
        value.splice(8, 0, str);
        return value.join("")
    }
}
app.mount('#app')
